import cplex
from time import time
from fs import fs
from callback import check_bigm_at_incumbent
from callback import check_bigm_at_branch

SZ = 40

f = open("results.txt","w")
c = fs()
c.parameters.read_file("../../param/stofac.prm")
c.gen_inst(NI = 2, NS = 50, RLB = 40, seed = 100)
c.solve()
f.write(str(c.solution.get_objective_value()) + "\n\n")
c.set_bigm(rank = [1,1])
c.register_callback(check_bigm_at_incumbent)
c.register_callback(check_bigm_at_branch)


#print c.M_rank
#print c.solution.progress.get_num_nodes_processed()
#c.solve()
"""
print c.solution.basis.get_basis()
print c.solution.get_linear_slacks()
print c.solution.get_objective_value()
print "--------"
print c.variables.get_names()
print c.solution.get_values()
"""
#c.set_problem_type(c.problem_type.LP)
for i in range(SZ):
    print c.M_rank
    c.solve()
    f.write(str(c.M_rank) + str(c.solution.get_objective_value()) + " " + str(c.flag) + "\n")
    c.set_bigm(rank = c.M_rank)
    c.flag = 1
f.close()
